<template>
	<view style="margin-top: 5rpx;">
		<u-list @scrolltolower="pageList">
			<u-list-item v-for="(item, key) in list">
				<view class="item-box row-box">
					<view class="time-box">
						{{item.createTime}}
						<view style="display: inline-block;margin-left: 20rpx;">
							<u-tag :type="item.type === 1 ? 'error': 'success'" :text="item.type === 1 ? '收入':'支出'" size="mini"></u-tag>
						</view>
					</view>
					<view :class="item.type === 1 ? 'up-box' : 'down-box'">
						￥{{item.money + " " + (item.type === 1? '↑':'↓')}}
					</view>
					<!-- ↑  ↓ -->
				</view>
			</u-list-item>
		</u-list>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				queryParams: {
					pageNum: 0,
					pageSize: 20
				},
				list: [],
				total: 0,
			}
		},
		onLoad() {
			this.getList();
		},
		methods: {
			getList() {
				this.$request("/wallet/changeInfo/list", "get", this.queryParams).then(res => {
					this.list.push(...res.rows);
					this.total = res.total;
					if(this.list.length < this.total)
						this.queryParams.pageNum++;
				})
			},
			
			pageList() {
				if(this.list.length >= this.total)
					return;
				this.getList();
			},
		}
	}
</script>

<style scoped lang="scss">
	.item-box {
		background-color: #fff;
		padding: 20rpx;
		border-bottom: 1px solid #e4e7ed;
		color: #303133;
		.time-box {
			width: 70%;
		}
		.up-box {
			width: 30%;
			text-align: right;
			color: #fa3534;
		}
		.down-box {
			width: 30%;
			text-align: right;
			color: #19be6b;
		}
	}
</style>
